import {BasicColumn, FormSchema} from '@apps/antd-admin/src/components/Table';
import {h} from 'vue';
import {Switch} from 'ant-design-vue';
import {Api as BrandApi} from '../../brand/data/brand.api';
import {Api as BscApi} from '../../bcs/data/bcs.api';

export const columns: BasicColumn[] = [
  {
    title: '车型名称',
    dataIndex: 'modelName',
    width: 280,
  },
  {
    title: '品牌',
    dataIndex: 'brandName',
    width: 100,
  },
  {
    title: '车系',
    dataIndex: 'seriesName',
    width: 100,
  },
  {
    title: '厂商名称',
    dataIndex: 'makerName',
    width: 200,
  },
  {
    title: '指导价',
    dataIndex: 'modelPrice',
    width: 100,
  },
  {
    title: '年款',
    dataIndex: 'modelYear',
    width: 100,
  },
  {
    title: '燃料类型',
    dataIndex: 'fuelTypeName',
    width: 100,
  },
  {
    title: '功率',
    dataIndex: 'enginePowerKw',
    width: 100,
  },
  {
    title: '排量',
    dataIndex: 'outputVolume',
    width: 100,
  },
  {
    title: '驱动类型',
    dataIndex: 'driveName',
    width: 100,
  },
  {
    title: '驱动类型',
    dataIndex: 'driveType',
    width: 100,
  },
  {
    title: '车型状态',
    dataIndex: 'modelStatus',
    width: 100,
  },
  {
    title: '变速箱',
    dataIndex: 'gearbox',
    width: 100,
  },
  {
    title: '变速箱名称',
    dataIndex: 'gearName',
    width: 100,
  },
  {
    title: '发动机马力',
    dataIndex: 'enginePower',
    width: 100,
  },
  {
    title: '上市日期',
    dataIndex: 'marketDate',
    width: 150,
  },
  {
    title: '排放标准',
    dataIndex: 'discharge',
    width: 100,
  },
  {
    title: '进气方式',
    dataIndex: 'intake',
    width: 100,
  },
  {
    title: '车身类型',
    dataIndex: 'bodyType',
    width: 100,
  },
  {
    title: '门数',
    dataIndex: 'doorNumber',
    width: 100,
  },
  {
    title: '座位数',
    dataIndex: 'seatNumber',
    width: 100,
  },
  {
    title: '更新时间',
    dataIndex: 'updateTime',
    width: 200,
  },
];

export const searchFormSchema: FormSchema[] = [{
  field: 'brandId',
  label: '品牌',
  component: 'ApiSelect',
  colProps: {span: 3},
  componentProps: ({formModel, formActionType}) => {
    return {
      api: BrandApi.list,
      labelField: 'brandName',
      valueField: 'brandId',
      immediate: true,
      showSearch: true,
      onChange(brandId) {
        formModel.seriesId = null;
        const {updateSchema} = formActionType;
        updateSchema(
            {
              field: 'seriesId',
              componentProps: {
                api: BscApi.list,
                immediate: false,
                labelField: 'seriesName',
                valueField: 'seriesId',
                showSearch: true,
                params: {
                  brandId: brandId
                }
              },
            }
        );
      },
    };
  },
}, {
  field: 'seriesId',
  label: '车系',
  component: 'ApiSelect',
  colProps: {span: 3}
}];

export const formSchema: FormSchema[] = [
  {
    label: '车系ID',
    field: 'seriesId',
    component: 'Input',
    required: true,
  },
  {
    label: '品牌ID',
    field: 'brandId',
    component: 'Input',
    required: true,
  },
  {
    label: '品牌名称',
    field: 'brandName',
    component: 'Input',
    required: true,
  },
  {
    label: '车系名称',
    field: 'seriesName',
    component: 'Input',
    required: true,
  },
  {
    label: '车型名称',
    field: 'modelName',
    component: 'Input',
    required: true,
  },
  {
    label: '车型',
    field: 'shortName',
    component: 'Input',
    required: true,
  },
  {
    label: '车系组 id',
    field: 'seriesGroupId',
    component: 'Input',
    required: true,
  },
  {
    label: '车系组名称',
    field: 'seriesGroupName',
    component: 'Input',
    required: true,
  },
  {
    label: '厂商名称',
    field: 'makerName',
    component: 'Input',
    required: true,
  },
  {
    label: '车型指导价',
    field: 'modelPrice',
    component: 'Input',
    required: true,
  },
  {
    label: '年款',
    field: 'modelYear',
    component: 'Input',
    required: true,
  },
  {
    label: '最小上牌年份',
    field: 'minRegYear',
    component: 'Input',
    required: true,
  },
  {
    label: '最大上牌年份',
    field: 'maxRegYear',
    component: 'Input',
    required: true,
  },
  {
    label: '燃料类型',
    field: 'fuelTypeName',
    component: 'Input',
    required: true,
  },
  {
    label: '功率',
    field: 'enginePowerKw',
    component: 'Input',
    required: true,
  },
  {
    label: '是否新能源',
    field: 'isGreen',
    component: 'Input',
    required: true,
  },
  {
    label: '排量',
    field: 'outputVolume',
    component: 'Input',
    required: true,
  },
  {
    label: '公告号',
    field: 'modelCode',
    component: 'Input',
    required: true,
  },
  {
    label: '驱动类型',
    field: 'driveName',
    component: 'Input',
    required: true,
  },
  {
    label: '驱动类型',
    field: 'driveType',
    component: 'Input',
    required: true,
  },
  {
    label: '车型状态：在售,停售,未知',
    field: 'modelStatus',
    component: 'Input',
    required: true,
  },
  {
    label: '变速箱类型：手动 ，自动 , 单速',
    field: 'gearbox',
    component: 'Input',
    required: true,
  },
  {
    label: '变速箱名称',
    field: 'gearName',
    component: 'Input',
    required: true,
  },
  {
    label: '新能源类型名称',
    field: 'greenTypeName',
    component: 'Input',
    required: true,
  },
  {
    label: '发动机马力',
    field: 'enginePower',
    component: 'Input',
    required: true,
  },
  {
    label: '上市日期',
    field: 'marketDate',
    component: 'Input',
    required: true,
  },
  {
    label: '排放标准',
    field: 'discharge',
    component: 'Input',
    required: true,
  },
  {
    label: '停产年份',
    field: 'stopMakeYear',
    component: 'Input',
    required: true,
  },
  {
    label: '进气方式',
    field: 'intake',
    component: 'Input',
    required: true,
  },
  {
    label: '车身类型',
    field: 'bodyType',
    component: 'Input',
    required: true,
  },
  {
    label: '门数',
    field: 'doorNumber',
    component: 'Input',
    required: true,
  },
  {
    label: '车身结构',
    field: 'carStruct',
    component: 'Input',
    required: true,
  },
  {
    label: '是否为平行进口车 0: 否 1: 是',
    field: 'isParallel',
    component: 'Input',
    required: true,
  },
  {
    label: '新能源价格描述',
    field: 'priceAllowance',
    component: 'Input',
    required: true,
  },
  {
    label: '座位数',
    field: 'seatNumber',
    component: 'Input',
    required: true,
  },
  {
    label: '其他参数',
    field: 'carParams',
    component: 'Input',
    required: true,
  },
  {
    label: '创建时间',
    field: 'createTime',
    component: 'Input',
    required: true,
  },
  {
    label: '更新时间',
    field: 'updateTime',
    component: 'Input',
    required: true,
  },
];
